package component.controls.ui
{
	import component.controls.Label;
	import component.controls.interfaces.ITip;
	import component.global.utils.DisplayUtils;
	import component.global.utils.FilterUtil;
	import component.global.utils.GraphicsUtils;
	
	import flash.display.DisplayObject;
	import flash.display.Shape;
	import flash.display.Sprite;
	
	public class Tip extends Sprite implements ITip
	{
		public function Tip()
		{
			super();
			init();
		}
		
		protected var _background:Shape;
		protected var _label:Label;
		protected var _tipData:*;
		
		protected function init():void{
			_background = GraphicsUtils.createRectangle();
			_background.filters = [FilterUtil.createDropShadowFilter(45),FilterUtil.createDropShadowFilter(45,true)];
			
			_label = new Label();
			_label.x = 2;
			_label.autoSize = "left";
			
			DisplayUtils.addDisplayObject(this, _background,_label);
		}
		
		public function set tipData(data:*):void{
			if(!data || !data.text)return;
			_label.text = data.text;
			updateTransform();
		}
		
		protected function updateTransform():void{
			_background.width = _label.width + 4;
		}
		
		public function get asDisplayObject():DisplayObject{
			return this as DisplayObject;
		}
	}
}